using System;
using System.Collections.Generic;
using System.Text;
using Dominio;
using DAP;

namespace Presenters
{
    public class ReleaseListPresenter
    {
        private ReleaseRepository repository;

        public ReleaseListPresenter()
        {
            repository = new ReleaseRepository();
        }
        public IList<Release> loadReleaseList(Object obj)
        {
            User user = (User)obj;
            IList<Release> releases = repository.getReleaseList();
            IList<Release> filteredReleases = new List<Release>();
            foreach (Familia f in user.Familias)
            {
                foreach (Patente p in f.Patentes)
                {
                    if (!user.Patentes.Contains(p))
                    {
                        user.Patentes.Add(p);
                    }
                }
                
            }
         
        foreach (Release rel in releases)
	    {
            foreach (Patente pat in user.Patentes)
            {
                if (pat.Country.Equals(rel.Country))
                {
                    rel.getMaturity();
                    filteredReleases.Add(rel);
                }
            }
	    }
        return filteredReleases;
        }


        public IList<Release> loadFilteredReleaseList(String from, String to, String state, String key)
        {
            return repository.getFilteredReleaseList(from, to, state, key);
        }
    }
}
